﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Globalization;
using System.Web.UI.WebControls;
using System.Net.Mail;


[WebService(Namespace = "http://www.avila.edu/WebServices/ScholarshipCalc")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class Service : System.Web.Services.WebService
{
  
    [WebMethod]
    public string estValue(string gpa, string sat, string act)
    {
        string SATVal, col, ACTVal; 
        int sVal, aVal; 
        double gpaVal;
        //string res;
        gpaVal = double.Parse(gpa);
        dbConn obj = new dbConn();
        if ((gpa != "") && (sat != "" || act != "")) // gpa,sat,Act if
        {
           
            if (gpaVal > 4.0 && gpa != "")
            {
                col = obj.getColName(gpaVal);

                if (sat != "")
                {
                    SATVal = obj.findSATVal(sat, col);
                    sVal = int.Parse(SATVal);
                    aVal = 0;
                    if (sVal <= 0 && aVal <= 0)
                        return "Not applicable";
                 
                    else
                    {
                        string res;
                        res = "Congratulations! Once admitted, you are " + System.Environment.NewLine + " likely to receive " + String.Format("{0:C0}", obj.estValue(sVal, aVal)) + " per year ";
                        res += System.Environment.NewLine + "(4 year Value = " + String.Format("{0:C0}", (4 * (obj.estValue(sVal, aVal)))) + ")";


                        res = res.Replace(System.Environment.NewLine, "\n");

                        return res;
                    }
                        //return "Congratulations! Once admitted, you are" + Environment.NewLine + " likely to receive " + String.Format("{0:C0}", obj.estValue(sVal, aVal)) + " per year" + Environment.NewLine + " (4 year Value = " + String.Format("{0:C0}", (4 * (obj.estValue(sVal, aVal)))) + ")";

                        //return "Congratulations! Once admitted, you are<br /> likely to receive " + Environment.NewLine + String.Format("{0:C0}", obj.estValue(sVal, aVal)) + " per year<br />" + " (4 year Value = " + String.Format("{0:C0}", (4 * (obj.estValue(sVal, aVal)))) + ")";
                }//if (sat != "")
                else if (act != "")
                {
                    ACTVal = obj.findACTVal(act, col);

                    aVal = int.Parse(ACTVal);
                    sVal = 0;
                    if (sVal <= 0 && aVal <= 0)
                        return "Not applicable";
                    else
                    {
                        string res;
                        res = "Congratulations! Once admitted, you are " + System.Environment.NewLine + " likely to receive " + String.Format("{0:C0}", obj.estValue(sVal, aVal)) + " per year ";
                        res += System.Environment.NewLine + "(4 year Value = " + String.Format("{0:C0}", (4 * (obj.estValue(sVal, aVal)))) + ")";


                        res = res.Replace(System.Environment.NewLine, "\n");
                       
                        return res;
                    }
                        //return "Congratulations! Once admitted, you are likely to receive " + String.Format("{0:C0}", obj.estValue(sVal, aVal)) + " per year" + " (4 year Value = " + String.Format("{0:C0}", (4 * (obj.estValue(sVal, aVal)))) + ")";
                }//if (act != "")


            }
                //else if (gpaVal >= 2.0 && gpaVal <= 3.24) Modified on 9/4/13
            else if (gpaVal >= 2.0 && gpaVal <= 4.0)
            {
                col = obj.getColName(gpaVal);
              
                    if (sat != "")
                    {
                        SATVal = obj.findSATVal(sat, col);
                        sVal = int.Parse(SATVal);
                        aVal = 0;
                        if ((col == "x200224x" && sat == "770-810") || (col == "x200224x" && sat == "820-850") || (col == "x200224x" && sat == "860-890") || (col == "x200224x" && sat == "900-930") || (col == "x200224x" && sat == "940-970") || (col == "x200224x" && sat == "980-1010") || (col == "x200224x" && sat == "1020-1050") ||
                            (col == "x225249x" && sat == "770-810") || (col == "x225249x" && sat == "820-850") || (col == "x225249x" && sat == "860-890") || (col == "x225249x" && sat == "900-930") ||
                            (col == "x250274x" && sat == "770-810") || (col == "x250274x" && sat == "820-850") ||
                            (col == "x275299x" && sat == "770-810") || (col == "x275299x" && sat == "820-850") ||
                            (col == "x30324x" && sat == "770-810") ||
                            (col == "x325349x" && sat == "770-810") ||
                           (col == "x350374x" && sat == "770-810") ||
                            (col == "x37540x" && sat == "770-810") 
                            )

                            return "Please contact the Office of Admission for more information on your scholarships";
                        else
                        {
                            string res;
                            res = "Congratulations! Once admitted, you are " + System.Environment.NewLine + " likely to receive " + String.Format("{0:C0}\n", obj.estValue(sVal, aVal)) + " per year        " + "   ";
                            res += Environment.NewLine ; // not working

                            res += "(4 year Value = "+ String.Format("{0:C0}", (4 * (obj.estValue(sVal, aVal)))) + ")";
                            

                            return res;
                        }
                    }
                    else if (act != "")
                    {
                        ACTVal = obj.findACTVal(act, col);

                        aVal = int.Parse(ACTVal);
                        sVal = 0;
                        if ((col == "x200224x" && act == "16") || (col == "x200224x" && act == "17") || (col == "x200224x" && act == "18") || (col == "x200224x" && act == "19") || (col == "x200224x" && act == "20") || (col == "x200224x" && act == "21") || (col == "x200224x" && act == "22") ||
                            (col == "x225249x" && act == "16") || (col == "x225249x" && act == "17") || (col == "x225249x" && act == "18") || (col == "x225249x" && act == "19") ||
                            (col == "x250274x" && act == "16") || (col == "x250274x" && act == "17") ||
                            (col == "x275299x" && act == "16") || (col == "x275299x" && act == "17") ||
                            (col == "x30324x" && act == "16") ||
                             (col == "x325349x" && act == "16") ||
                           (col == "x350374x" && act == "16") ||
                            (col == "x37540x" && act == "16") 
                           
                            
                            
                            )
                            return "Please contact the Office of Admission for more information on your scholarships";
                        else
                           // return "Congratulations! Once admitted, you are likely to receive " + String.Format("{0:C0}", obj.estValue(sVal, aVal)) + " per year" + " (4 year Value = " + String.Format("{0:C0}", (4 * (obj.estValue(sVal, aVal)))) + ")";
                            return "Congratulations! Once admitted, you are " + "\n" + "likely to receive " + String.Format("{0:C0}", obj.estValue(sVal, aVal)) + " per year" + "\n" + " (4 year Value = " + String.Format("{0:C0}", (4 * (obj.estValue(sVal, aVal)))) + ")";

                    
                    }
                
             
            }

            //else if (gpaVal >= 3.25 && gpaVal <= 3.49)
            //{
            //    col = obj.getColName(gpaVal);

            //    if (sat != "")
            //    {
            //        SATVal = obj.findSATVal(sat, col);
            //        sVal = int.Parse(SATVal);
            //        aVal = 0;
            //        if ( (col == "x325349x" && sat == "770-810")

            //            )

            //            return "Please contact the Office of Admission for more information on your scholarships";
            //        else
            //        {
            //            string res;
            //            res = "Congratulations! Once admitted, you are ";
            //            res += Environment.NewLine;
            //            res += "likely to receive " + String.Format("{0:C0}", obj.estValue(sVal, aVal)) + " per year";
            //            res += Environment.NewLine;
            //            res += " (4 year Value = " + String.Format("{0:C0}", (4 * (obj.estValue(sVal, aVal)))) + ")";
                       
                          
            //            //res = "Congratulations! Once admitted, you are likely to receive ";
            //            //res += Environment.NewLine;
            //            //res += String.Format("{0:C0}", obj.estValue(sVal, aVal)) + " per year" + " (4 year Value = " + String.Format("{0:C0}", (4 * (obj.estValue(sVal, aVal)))) + ")";
            //            //return res;
            //        }
            //    }
            //    else if (act != "")
            //    {
            //        ACTVal = obj.findACTVal(act, col);

            //        aVal = int.Parse(ACTVal);
            //        sVal = 0;
            //        if ((col == "x325349x" && act == "16")



            //            )
            //            return "Please contact the Office of Admission for more information on your scholarships";
            //        else
            //            //return "Congratulations! Once admitted, you are likely to receive " + String.Format("{0:C0}", obj.estValue(sVal, aVal)) + " per year" + " (4 year Value = " + String.Format("{0:C0}", (4 * (obj.estValue(sVal, aVal)))) + ")";
            //            return "Congratulations! Once admitted, you are" + "<br/>" + " likely to receive " + String.Format("{0:C0}", obj.estValue(sVal, aVal)) + " per year" + "<br/>" + " (4 year Value = " + String.Format("{0:C0}", (4 * (obj.estValue(sVal, aVal)))) + ")";


            //    }


           // }





            // return "Not Qualified";
            return " Please contact an admission counselor at 816.501.2400 ";

        }// gpa,sat,Act if<body>

        else if ((sat == "" || act == " ") && (gpa != ""))
            return "Enter SAT - OR - ACT";
        else
            return "Enter Numeric GPA (AND) SAT -or- ACT ";



    }
    
}
